using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;

public class Fadable : MonoBehaviour
{
    [SerializeField]
    private float _fadeTime = 0.5f;

    private CanvasGroup _canvasGroup;

    private Tween _tween = null;


    private void Awake()
    {
        _canvasGroup = GetComponent<CanvasGroup>();
        _canvasGroup.alpha = 0f;
    }

    public void FadeIn()
    {
        _tween?.Kill();
        _tween = _canvasGroup.DOFade(1f, _fadeTime);
    }

    public void FadeOut()
    {
        _tween?.Kill();
        _tween = _canvasGroup.DOFade(0f, _fadeTime);
    }
}
